/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
#include"PublicTool.h"
#include"PublicLog.h"
#include"CSwitchManager.h"
#include"SnmpApi.h"
void testhelp(){
	INFO("-ip:0.0.0.0 -c:public -app:appname");
}
void test(int argc, char** argv){
	int i=1;
	char ip[64]={0};
	char community[256]={0};
	char appname[256]={0};
	for(i=1;i<argc;i++){
		if(strncmp(argv[i],"-ip:",4)==0){
			strcpy(ip,argv[i]+4);
		}else
		if(strncmp(argv[i],"-c:",3)==0){
			strcpy(community,argv[i]+3);
		}else
		if(strncmp(argv[i],"-app:",5)==0){
			strcpy(appname,argv[i]+5);
		}else{
			testhelp();
			return;
		}
	}
	if(ip[0]=='\0'||community[0]=='\0'||appname[0]=='\0'){
		testhelp();
		return ;
	}
	InitNetSnmp();
	UpdateSnmpCommunity(ip,community);
	SNMPSYSPACKET sysinfo=GetSnmpInfoByIP(ip,community,5000);
	if(sysinfo.snmptime>0){
		CSwitchData*data=new CSwitchData(ip);
		data->UpdateSwitchSysInfo(sysinfo);
		data->UpDateSwitchData(SWITCH_DATA_FLAG_ROUTETABLE|SWITCH_DATA_FLAG_DEBUG);
		data->UpLoadToServer();
		delete data;

		CSwitchifTable*ifdata=new CSwitchifTable(ip);
		ifdata->UpDateifTable();
		delete ifdata;

	}else{
		WRONG("SNMP探测超时 %d",sysinfo.snmptime);
	}
}